﻿<link href="@Url.Content("~/content/activitie_detail.css")" rel="stylesheet" type="text/css" />
<style>
    #sFly1 textarea {
        width:96%;
     }
</style>

@model PessMvc.Models.ArchiveGradeModel

@{
    ViewBag.Title = "Grade";
}
<div id="m-title">
    <h2>评分</h2>
    <div id="m-op">
        @Html.ActionLink("返回", "Index", new { activityID = Model.ActivityID, archiveID = Model.Archive.ID }, null)
    </div>
</div>

@if (Model.IsArchiveProfileVisible)
{
    @Html.Partial("_ArchiveDetailsPartial", Model.Archive, new ViewDataDictionary() { { "HideArchiveDetails", Model.HideArchiveDetails } , { "ArchiveDisplayNames",ViewBag.ArchiveDisplayNames} })
}

@if (Model.IsArchiveBasicInfoVisible)
{
    @*<div style="display:none;">
        <div>@Html.LabelFor(model => model.Archive.ProjectTitle)</div>
        <div>@Model.Archive.ProjectTitle</div>
        <div>@Html.LabelFor(model => model.Archive.SerialNumber)</div>
        <div>@Model.Archive.SerialNumber</div>
        <div>@Html.LabelFor(model => model.Archive.SchoolComment)</div>
        <div>@Model.Archive.SchoolComment</div>
        <div>@Html.LabelFor(model => model.Archive.CountyEBComment)</div>
        <div>@Model.Archive.CountyEBComment</div>
    </div>*@
}


<div class="f-grade" style="position:relative;overflow:hidden;">
    @if (Model.IsArchivePDFVisible)
    {
        <div style="width:795px;float:left;padding-top:2px;padding-right:0px;padding-left:0px;margin-top:-50px;overflow:hidden;">
            <object data=@Url.Action("GetPDF", new { archiveID=Model.Archive.ID}) type="application/pdf" style="width:99%;height:850px;">
                alt : <a href="http://down.tech.sina.com.cn/download/d_load.php?d_id=8255&down_id=1&ip=61.170.136.41">下载PDF阅读器。</a>
            </object>
        @if (Model.IsArchiveAttachmentVisible)
        {
            <div id="showFile" class="displayValue" style="width:790px;margin-top:10px;">
            @{
                var grid = new WebGrid(Model.Archive.Attachments, defaultSort: "Title");
            }
            @grid.GetHtml(columns: from c in grid.Columns(
                 grid.Column("Title", header: " 文件名 ", format: @<text>@Html.ActionLink((string)item.Title, "Download", "Archive", new { archiveID = Model.Archive.ID, title = (string)item.Title }, null)</text>, style:"thAction2"),
                 grid.Column("FileSize", header: " 文件大小（KB） "),
                 grid.Column("TimeStamp", header: " 最后修改时间 "),
                 grid.Column("Operation", header: "操作", format: @<text>@if(Model.IsModificationAllowed){Html.ActionLink("删除", "DeleteAttachment", "Archive", new { archiveID = Model.Archive.ID, title = (string)item.Title }, null);}</text>)
            )
                                           where !c.ColumnName.Contains("Operation") || (Roles.IsUserInRole("Admin") || Roles.IsUserInRole("CountyAdmin"))
                                           select c
                                                                              )
                </div>
        }
        </div>
        
    }

    <fieldset class="edit" style="width:368px;float:right;padding-top:0px;margin-left:0px;margin-right:0px;position:relative;">
        <legend style="font-size:14px;">@Html.DisplayNameFor(model => model.Archive.SerialNumber)：@ViewBag.SerialNumber</legend>
        @using (Html.BeginForm("Grade", "Archive", FormMethod.Post))
        {
            @Html.Hidden("ArchiveID", Model.Archive.ID)
            @Html.Hidden("page",Model.Page)
            @Html.ValidationSummary(true)
            <div class="u-gd-tb">
                <table style="width:366px;" id="sFly">
                    <tr>
                        <th>名称</th>
                        @*<th>说明</th>*@
                        <th>分值</th>
                        <th></th>
                    </tr>
                    @{var scoreList = Model.Scores.ToList();}
                    @for (int i = 0; i < scoreList.Count(); i++)
                    {
                        <tr style="text-align:center;">
                            <td style="width:266px" alt="@scoreList[i].Description" title="@scoreList[i].Description">@scoreList[i].Name</td>
                            @*<th>@scoreList[i].Description</th>*@
                            <td style="width:30px">@scoreList[i].Value</td>
                            <td style="width:48px">
                                @Html.Hidden("scoreList[" + i + "].ID", scoreList[i].ID)
                                @Html.Hidden("scoreList[" + i + "].ArchiveID", Model.Archive.ID)
                                @if (scoreList[i].InputControl == null || scoreList[i].InputControl == (int)PessModel.InputControlMode.TextBox)
                                {
                                    @Html.TextBox("scoreList[" + i + "].ScoreValue", (object)scoreList[i].ScoreValue == null ? 0 : (decimal)scoreList[i].ScoreValue, new { style = "width:40px" })
                                }
                                else
                                {
                                    @Html.ScoreInputControl("scoreList[" + i + "].ScoreValue", (int)scoreList[i].Value, (object)scoreList[i].ScoreValue == null ? 0 : (int)scoreList[i].ScoreValue)
                                }
                            </td>
                        </tr>
                    }
                </table>
                @*<p>指标1和2的总分在10分以上为通过；
                    指标3的分值为1表示通过，0表示不通过。</p>*@
                <p>@ViewBag.ScoringInstruction</p>
            </div>
            <div style="text-align:center">
                @Html.TextArea("Comment", new { style = "width:364px;height:240px;margin-top:5px;margin-bottom:8px;", onclick = "if (this.innerHTML=='请输入评语') {this.innerHTML='';}", onblur = "if (this.innerHTML=='') {this.innerHTML='请输入评语';}" })
            </div>
            <div id="noScript">
                <p>您的浏览器禁用了JS支持，无法查看总分。请启用JS或更换浏览器。</p>
            </div>
            <div id="sum" style="display:none">
                总分合计： <span id="sum"></span> 分
            </div>
            if (Model.IsGradingAllowed && Model.IsRespondingByStandardAllowed)
            {
            <div class="u-gd-tb">
                <p>分项评语：</p>
                    <table style="width:366px;" id="sFly1">
                         <tr>
                            <th>名称</th>
                            <th>评语</th>
                        </tr>
                        @{var responseList = Model.Responses.ToList();}
                        @for (int i = 0; i < responseList.Count(); i++)
                        {
                            <tr style="text-align:center;">
                                <td style="width:40px">@responseList[i].Title</td>
                                @*<th>@scoreList[i].Description</th>*@
                                <td style="width:226px">
                                @Html.Hidden("responseList[" + i + "].StandardID", responseList[i].ID)
                                @Html.Hidden("responseList[" + i + "].ArchiveID", Model.Archive.ID)
                                @Html.TextArea("responseList[" + i + "].Comment", responseList[i].Comment)                                
                            </td>
                               
                            </tr>
                        }
                    </table>
            </div>
            }
            if(Model.IsGradingAllowed&&Model.IsGradeAssignmentAllowed)
            {
                 <div class="u-gd-tb">
                     <p>建议等第：</p>
                     @Html.GradeInputControl("selectedGradeRuleID",Model.AvailableGradRules,Model.ExpertGrade )
                 </div>
            }
            if (Model.IsGradingAllowed)
            {
                <span class="editor-btn-inLine downM" style="padding-left:12px;padding-right:8px;"><input type="submit" value="保存" class="u-btn" /> </span>
            }
            else
            {
                <p>
                    只有在从 @Model.Archive.ScheduledDate 起的两天以内可评分。
                </p>
            }
        }
        @if (Model.IsGradingAllowed)
        {
            <span class="editor-btn-inLine downM">
                @using (Html.BeginForm("DeleteScores2", "Score", FormMethod.Post))
                {
                    @Html.Hidden("ArchiveID", Model.Archive.ID)
                    <input type="submit" value="删除分数" class="f-btn-delS" style="width: 60px; color: #d9534f; border: none; height: 24px; line-height:24px; top: 5px; cursor: pointer;" />
                }
            </span>
        }
        @*<p style="padding-top:15px;" class="thAction2"><a href="http://jy.sjys.cn/jq/11809294.aspx">数字教材应用情况分析</a></p>*@
    </fieldset>                        
                       
</div>

<p style="clear:both;">&nbsp; </p>
        @if (Model.IsArchiveHistroyVisible)
        {
            @Html.Partial("_PreviousArchivesPartial", new ViewDataDictionary(Model.PreviousArchives))
        }
        
<script type="text/javascript">
    //document.getElementById("Comment").innerHTML = "请输入评语";
</script>
<script type="text/javascript">
    //document.getElementById("Comment").innerHTML = "请输入评语";
    $('#noScript').css("display", "none");
    $('#sum').css("display", "block");
    $(document).ready(function () {
        var tmpS = 0;
        var tmpT = 0;
        $('#sFly select').each(function (index) {
            $(this).change(function () {
                tmpS = 0;
                $('#sFly select').each(function (index) {
                    tmpS += parseInt($(this).find('option:selected').attr('value'));
                });
                $('#sum span').text(tmpS+tmpT);
            });
            tmpS += parseInt($(this).find('option:selected').attr('value'));
        });
        $('#sFly input[type="text"]').each(function (index) {
            $(this).change(function () {
                tmpT = 0;
                $('#sFly input[type="text"]').each(function (index) {
                    tmpT += parseInt($(this).val());
                });
                $('#sum span').text(tmpS+tmpT);
            });
            tmpT += parseInt($(this).val());
        });
        $('#sum span').text(tmpS+tmpT);
    });
</script>
